<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

</head>
<body>
<!--显示成绩－模态框（Modal）-->
<div  class="modal fade"  id="showScoreModal"  tabindex="-1"  role="dialog"  aria-labelledby="showScoreModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="showScoreModalLabel">查看科目成绩</h4>
			</div>
			<div class="modal-body">
				<p><label>用户名:</label><label id="userName"></label></p>
				<p><label>科目名:</label><label id="subjectName"></label></p>
				<p><label>考试时间:</label><label id="examTime"></label></p>
				<p><label>得分:</label><label id="score"></label></p></div>
			<div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			<button id="scorePrint"type="button" class="btn btn-primary">打印</button>
			</div>
		</div>
		<!--/.modal-content -->
	</div>
		<!--/.modal -->
</div>
<table id="sample-table-1" class="table table-striped table-bordered table-hover">
											<thead>
												<tr>
													
													<th>科目ID</th>
													<th>科目名称</th>
													<th>科目描述</th>
													<th>科目题数</th>
													<th>考试时长</th>
													<th>考试总成绩</th>
													<th>考试成绩</th>
													<th>操作</th>
<!-- 													<th>题目类型</th> -->
<!-- 													<th>题目分数</th> -->
<!-- 													<th>操作</th> -->
												</tr>
											</thead>

											<tbody>
											<c:forEach items="${studentSubjectList }" var="subjectVO">
												<tr>
													<td>${subjectVO.id }</td>
													<td>${subjectVO.name }</td>
													<td>${subjectVO.description }</td>
													<td>${subjectVO.count }</td>
													<td>${subjectVO.time }</td>
													<td>${subjectVO.score }</td>
													<c:if test="${subjectVO.testscore == null}">
														<td>未参加考试</td>
													</c:if>
													<c:if test="${subjectVO.testscore != null}">
														<td>${subjectVO.testscore }</td>
													</c:if>
<%-- 													<td>${subjectVO.status }</td> --%>
													<td>
															<c:if test="${subjectVO.testscore != null}">
															<button title="查看成绩单" class="btn btn-primary btn-xs showExamTestScore" type="button">
																<i class="ace-icon fa fa-comment"></i>
															</button>
															</c:if>
															
															<c:if test="${subjectVO.testscore == null}">
															<c:if test="${subjectVO.status == true}">
															<a title="马上参加考试" class="btn btn-primary  btn-xs toExamTestBtn" type="button" href="${pageContext.request.contextPath}/toExamTest/${subjectVO.id}">
																<i class="ace-icon fa fa-pencil"></i>
															</a>
															</c:if>
															<c:if test="${subjectVO.status == false}">
															<a title="马上参加考试" class="btn btn-default  btn-xs">
																<i class="ace-icon fa fa-pencil"></i>
															</a>
															</c:if>
															</c:if>
<!-- 															<a title="删除试题" class="btn btn-primary btn-xs delete-test"> -->
<!-- 																<i class="ace-icon fa fa-trash-o"></i> -->
<!-- 															</a> -->
															

														
													</td>
												</tr>
												</c:forEach>
											</tbody>
										</table>
<script src="${pageContext.request.contextPath}/static/lib/jquery.jqprint-0.3.js"></script>
<script type="text/javascript">
 $(".toExamTestBtn").click(function(){
	 var subjectId = $(this).parent().siblings().eq(0).text();
	 if(confirm("只有一次机会进行考试,确定是否开始!")){
		 $.ajax({
				type:'POST',
				url:'testtoExamTest',
				data:{
					subjectId:subjectId,
					},
					dataType:"json",
					async:false,
					success:function(data){
						if(data.success){
							alert("身份验证成功");
							}
					},
					error:function(data, status, e){
						alert("系统繁忙"+e);
						}
				});
		 }else{
				return false;
			 }
	 });
 $(".showExamTestScore").click(function(){
	 var subjectId = $(this).parent().siblings().eq(0).text();
	 $.ajax({
			type:'POST',
			url:'getSubjectScore',
			data:{
				subjectId:subjectId,
				},
				dataType:"json",
				success:function(data){
					$("#userName").text(data.username);
					$("#subjectName").text(data.name);
					$("#examTime").text(data.examTime);
					$("#score").text(data.testscore);
				},
				error:function(data, status, e){
					alert("系统繁忙"+e);
					}
			});
	 $("#showScoreModal").modal("show");
	 });
 $('#scorePrint').click(function() {
	 $('#showScoreModal .modal-body').jqprint();
	 });
</script>
</body>
</html>